package org.ala.shopping_test.shopping_center.repository.order_buyer.orderBy;

import java.util.List;
import java.util.ArrayList;
import org.ala.shopping_test.shopping_center.repository.order_buyer.entity.ShoppingOrderBuyerDO;
import org.ala.tiktools.mybatis.interfaces.AbstractOrderBy;
import org.ala.tiktools.mybatis.interfaces.IComparator;


/**
 *	OrderBy (shopping_order_buyer)
 *  订单总表
 *
 *	@author 骆毅 (ala)
 *	@date 2025-03-24 15:40:25
 */
public class ShoppingOrderBuyerOrderBy extends AbstractOrderBy<ShoppingOrderBuyerDO> {

    /**
     *  主要用于分表查询时的汇总排序
     *  <p> 当分表查询跨多个分表，同时查询又带有排序，需要额外的逻辑将多个分表的查询结果汇总
     */
    public ShoppingOrderBuyerOrderBy comparator(IComparator<ShoppingOrderBuyerDO> comparator) {
        this.comparator = comparator;
        return this;
    }

    public static String Id = "id";
    public static String OrderId = "order_id";
    public static String SellerOrderId = "seller_order_id";
    public static String Code = "code";
    public static String BuyerId = "buyer_id";
    public static String BuyerName = "buyer_name";
    public static String SellerId = "seller_id";
    public static String SellerName = "seller_name";
    public static String OrderAmount = "order_amount";
    public static String OrderTax = "order_tax";
    public static String OrderDiscountAmount = "order_discount_amount";
    public static String OrderProfit = "order_profit";
    public static String OrderAmountDetail = "order_amount_detail";
    public static String Status = "status";
    public static String Abnormal = "abnormal";
    public static String Remark = "remark";
    public static String CreateTime = "create_time";
    public static String ModifyTime = "modify_time";

    protected List<Item> items;
    public List<Item> getItems() {return items;}

    public static ShoppingOrderBuyerOrderBy build(String field, boolean isAsc) {
        ShoppingOrderBuyerOrderBy ob = new ShoppingOrderBuyerOrderBy();
        ob.items = new ArrayList<>();
        ob.items.add(Item.build(field, isAsc));
        return ob;
    }
    public static ShoppingOrderBuyerOrderBy ASC(String field) { return build(field, true); }
    public static ShoppingOrderBuyerOrderBy DESC(String field) { return build(field, false); }

    public ShoppingOrderBuyerOrderBy Aas(String field) { items.add(Item.build(field, true)); return this; }
    public ShoppingOrderBuyerOrderBy Desc(String field) { items.add(Item.build(field, false)); return this; }

    /**
     *  根据字段名取值
     */
    public Object getVal(ShoppingOrderBuyerDO e, Item item) {
        if (item.getColumn().equals(Id)) {return e.getId();}
        if (item.getColumn().equals(OrderId)) {return e.getOrderId();}
        if (item.getColumn().equals(SellerOrderId)) {return e.getSellerOrderId();}
        if (item.getColumn().equals(Code)) {return e.getCode();}
        if (item.getColumn().equals(BuyerId)) {return e.getBuyerId();}
        if (item.getColumn().equals(BuyerName)) {return e.getBuyerName();}
        if (item.getColumn().equals(SellerId)) {return e.getSellerId();}
        if (item.getColumn().equals(SellerName)) {return e.getSellerName();}
        if (item.getColumn().equals(OrderAmount)) {return e.getOrderAmount();}
        if (item.getColumn().equals(OrderTax)) {return e.getOrderTax();}
        if (item.getColumn().equals(OrderDiscountAmount)) {return e.getOrderDiscountAmount();}
        if (item.getColumn().equals(OrderProfit)) {return e.getOrderProfit();}
        if (item.getColumn().equals(OrderAmountDetail)) {return e.getOrderAmountDetail();}
        if (item.getColumn().equals(Status)) {return e.getStatus();}
        if (item.getColumn().equals(Abnormal)) {return e.getAbnormal();}
        if (item.getColumn().equals(Remark)) {return e.getRemark();}
        if (item.getColumn().equals(CreateTime)) {return e.getCreateTime();}
        if (item.getColumn().equals(ModifyTime)) {return e.getModifyTime();}
        return null;
    }
}